<div class="layui-card">
    <div class="layui-card-header">
        <h2 class="header-title">玩家信息</h2>
        <span class="layui-breadcrumb pull-right">
          <a href="#!console">首页</a>
          <a><cite>查询系统</cite></a>
        </span>
    </div>
    <div class="layui-card-body">
        <div class="layui-form toolbar nowrap">
            搜索：
            <select id="test-search-key">
                <option value="">-请选择-</option>
                <option value="name">别称</option>
            </select>
            <input id="test-search-value" class="layui-input search-input" type="text" placeholder="输入关键字"/>&emsp;
            <input id="test-date" class="layui-input" type="text"/>
            <button id="test-btn-search" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索</button>
        </div>

        <table class="layui-table" id="test-table" lay-filter="table-filter"></table>
    </div>
</div>


<!-- 表格操作列 -->
<script type="text/html" id="test-table-bar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-xs" lay-event="reset">重置密码</a>
</script>

<!-- 表格状态列 -->
<script type="text/html" id="test-tpl-state">

</script>

<script>
    layui.use(['form', 'table', 'util', 'config', 'admin','laydate','layer'], function () {
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var layer = layui.layer;
        var util = layui.util;
        var admin = layui.admin;
        var laydate = layui.laydate;
        var layer = layui.layer;

        // 渲染表格
        table.render({
            elem: '#test-table',
            url: config.base_server + 'api-bsdld/t1',
            method: 'GET',
            where: {
                access_token: config.getToken().access_token
            },
            page: true,
            cols: [[
                <!--{type: 'numbers'},-->
                {field: 'id', sort: true, title: '编号', unresize: true},
                {field: 'playerId', sort: true, title: '玩家Id'},
                {field: 'name', sort: true, title: '昵称'},
                {field: 'sex', sort: true, title: '性别'},
                {field: 'phone', sort: true, title: '手机号'},
                {field: 'type', sort: true, title: '玩家类型'},
                {fixed: 'right', width:178, align:'center', toolbar: '#barDemo'}
            ]]
        });

        //监听工具条:lay-event对应值
        table.on('tool(table-filter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.msg('ID：' + data.id + ' 的查看操作');
            } else if (obj.event === 'del') {
                doDelete(data);
            } else if (obj.event === 'edit') {
                <!--layer.alert('编辑行：<br>' + JSON.stringify(data));-->
                showEditModel(data);
            }
        });

        <!-- 删除 -->
        var doDelete = function (obj) {
            layer.confirm('确定要删除吗？', function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('api-bsdld/testdel/' + obj.data.id, {}, function (data) {
                    layer.closeAll('loading');
                    if (data.resp_code == 0) {
                        layer.msg(data.resp_msg, {icon: 1, time: 500});
                        obj.del();
                    } else {
                        layer.msg(data.resp_msg, {icon: 2, time: 500});
                    }
                }, 'DELETE');
            });
        };
        <!-- 弹出层:编辑 -->
        var showEditModel = function (data) {
            admin.putTempData('t_test', data);
            admin.popupCenter({
                title: "编辑",
                path: 'pages/bsdld/bsdld_form.html',
                finish: function () {
                    table.reload('test-table', {});
                }
            });
        };

        // 搜索按钮点击事件
        $('#test-btn-search').click(function () {
            var key = $('#test-search-key').val();
            var value = $('#test-search-value').val();
            var date = $('#test-date').val();

            table.reload('test-table', {where: {searchKey: key, searchValue: value, time: date}});
        });
        laydate.render({
            elem:'#test-date'
            ,type: 'datetime'
        });
    });






</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>

    <!-- 这里同样支持 laytpl 语法，如： -->
    {{#  if(d.auth > 2){ }}
    <a class="layui-btn layui-btn-xs" lay-event="check">审核</a>
    {{#  } }}
</script>